unit add_substep_unit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, Dialogs, data_module, cxGraphics, cxControls,
  cxLookAndFeels, cxLookAndFeelPainters, cxContainer, cxEdit, dxSkinsCore,
  dxSkinBlack, dxSkinBlue, dxSkinBlueprint, dxSkinCaramel, dxSkinCoffee,
  dxSkinDarkRoom, dxSkinDarkSide, dxSkinDevExpressDarkStyle,
  dxSkinDevExpressStyle, dxSkinFoggy, dxSkinGlassOceans, dxSkinHighContrast,
  dxSkiniMaginary, dxSkinLilian, dxSkinLiquidSky, dxSkinLondonLiquidSky,
  dxSkinMcSkin, dxSkinMoneyTwins, dxSkinOffice2007Black, dxSkinOffice2007Blue,
  dxSkinOffice2007Green, dxSkinOffice2007Pink, dxSkinOffice2007Silver,
  dxSkinOffice2010Black, dxSkinOffice2010Blue, dxSkinOffice2010Silver,
  dxSkinPumpkin, dxSkinSeven, dxSkinSevenClassic, dxSkinSharp, dxSkinSharpPlus,
  dxSkinSilver, dxSkinSpringTime, dxSkinStardust, dxSkinSummer2008,
  dxSkinTheAsphaltWorld, dxSkinsDefaultPainters, dxSkinValentine, dxSkinVS2010,
  dxSkinWhiteprint, dxSkinXmas2008Blue, ImgList, cxDropDownEdit, cxCalendar,
  cxDBEdit, cxDBLookupComboBox, cxTextEdit, cxMaskEdit, cxLookupEdit,
  cxDBLookupEdit, StdCtrls, Mask, DBCtrls, cxSpinEdit, Vcl.Grids, Vcl.ValEdit,
  cxStyles, dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, cxDataStorage,
  Data.DB, cxDBData, cxGridCustomTableView, cxGridTableView, cxGridDBTableView,
  cxGridLevel, cxClasses, cxGridCustomView, cxGrid;

type
  Tadd_substep_form = class(TForm)
    Label1: TLabel;
    Label3: TLabel;
    ok_button: TButton;
    cancek_button: TButton;
    Label4: TLabel;
    step_combo: TcxDBLookupComboBox;
    study_plan_combo: TcxLookupComboBox;
    ImageList1: TImageList;
    cxDBTextEdit1: TcxDBTextEdit;
    cxGrid1DBTableView1: TcxGridDBTableView;
    cxGrid1Level1: TcxGridLevel;
    cxGrid1: TcxGrid;
    Label2: TLabel;
    cxGrid1DBTableView1Column1: TcxGridDBColumn;
    cxGrid1DBTableView1Column2: TcxGridDBColumn;
    cxGrid1DBTableView1Column3: TcxGridDBColumn;
    cxGrid1DBTableView1Column4: TcxGridDBColumn;
    Label5: TLabel;
    cxDBTextEdit2: TcxDBTextEdit;
    procedure step_comboPropertiesChange(Sender: TObject);
    procedure cxDBTextEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
    groups_ids:array[1..100] of integer;
    groups_count:integer;
    insert:boolean;
  end;

var
  add_substep_form: Tadd_substep_form;

implementation

{$R *.dfm}

procedure Tadd_substep_form.cxDBTextEdit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var i:integer;
begin
  if Key=VK_RETURN then
    with data_mod do
    begin
      substeps_query.Post;
      if insert then
      for i := 1 to groups_count do
      begin
        MyQuery1.SQL.Clear;
        MyQuery1.SQL.Append('INSERT INTO substep_dates SET ');
        MyQuery1.SQL.Append('id_substep='+IntToStr(substeps_query.InsertId)+',');
        MyQuery1.SQL.Append('id_group='+IntToStr(groups_ids[i]));
        MyQuery1.Execute;
      end;
      substep_dates_query.ParamByName('id_substep').Value:=substeps_query.InsertId;
      substep_dates_query.ExecSQL;
    end;
end;

procedure Tadd_substep_form.step_comboPropertiesChange(Sender: TObject);
begin
//  with data_mod.substep_dates_query do
//  begin
//    ParamByName('id_substep').Value:=step_combo.EditValue;
//    ExecSQL;
//  end;
end;

end.
